
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Django入门与实践-第17章：保护视图 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="DjangoORM1.html" />
    
    
    <link rel="prev" href="Authentication2.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="GettingStarted.html">
            
                <a href="GettingStarted.html">
            
                    
                    Django入门与实践-第1章：环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="GettingStarted-2.html">
            
                <a href="GettingStarted-2.html">
            
                    
                    Django入门与实践-第2章：创建项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="gettingstarted-3.html">
            
                <a href="gettingstarted-3.html">
            
                    
                    Django入门与实践-第3章：Hello World
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Fundamentals-1.html">
            
                <a href="Fundamentals-1.html">
            
                    
                    Django入门与实践-第4章：系统设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="Fundamentals-2.html">
            
                <a href="Fundamentals-2.html">
            
                    
                    Django入门与实践-第5章：模型设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="Fundamentals-3-0.html">
            
                <a href="Fundamentals-3-0.html">
            
                    
                    Django入门与实践-第6章：第一个视图函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="Fundamentals-3-1.html">
            
                <a href="Fundamentals-3-1.html">
            
                    
                    Django入门与实践-第7章：模板引擎设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="Fundamentals-3-1-1.html">
            
                <a href="Fundamentals-3-1-1.html">
            
                    
                    Django入门与实践-第8章：第一个单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="Fundamentals-3-2.html">
            
                <a href="Fundamentals-3-2.html">
            
                    
                    Django入门与实践-第9章：静态文件设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="Fundamentals-4.html">
            
                <a href="Fundamentals-4.html">
            
                    
                    Django入门与实践-第10章：Django Admin 介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="AdvancedConcepts.html">
            
                <a href="AdvancedConcepts.html">
            
                    
                    Django入门与实践-第11章：URL 分发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="AdvancedConcept2.html">
            
                <a href="AdvancedConcept2.html">
            
                    
                    Django入门与实践-第12章：复用模板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="AdvancedConcept3.html">
            
                <a href="AdvancedConcept3.html">
            
                    
                    Django入门与实践-第13章：表单处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="Authentication0.html">
            
                <a href="Authentication0.html">
            
                    
                    Django入门与实践-第14章：用户注册
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="Authentication1.html">
            
                <a href="Authentication1.html">
            
                    
                    Django入门与实践-第15章：用户注销
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="Authentication2.html">
            
                <a href="Authentication2.html">
            
                    
                    Django入门与实践-第16章：用户登录
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.18" data-path="DjangoORM0.html">
            
                <a href="DjangoORM0.html">
            
                    
                    Django入门与实践-第17章：保护视图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="DjangoORM1.html">
            
                <a href="DjangoORM1.html">
            
                    
                    Django入门与实践-第18章：实现主题回复列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="DjangoORM2.html">
            
                <a href="DjangoORM2.html">
            
                    
                    Django入门与实践-第19章：实现主题回复功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="DjangoORM3.html">
            
                <a href="DjangoORM3.html">
            
                    
                    Django入门与实践-第20章：查询结果集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="DjangoORM.html">
            
                <a href="DjangoORM.html">
            
                    
                    Django入门与实践-第21章：Django数据迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="ClassBasedViews0.html">
            
                <a href="ClassBasedViews0.html">
            
                    
                    Django入门与实践-第22章：基于类的视图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="ClassBasedViews1.html">
            
                <a href="ClassBasedViews1.html">
            
                    
                    Django入门与实践-第23章：分页实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="ClassBasedViews2.html">
            
                <a href="ClassBasedViews2.html">
            
                    
                    Django入门与实践-第24章：我的账户
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="ClassBasedViews3.html">
            
                <a href="ClassBasedViews3.html">
            
                    
                    Django入门与实践-第25章：Markdown支持
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" data-path="ClassBasedViews4.html">
            
                <a href="ClassBasedViews4.html">
            
                    
                    Django入门与实践-第26章：个性化设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.28" data-path="Deployment.html">
            
                <a href="Deployment.html">
            
                    
                    Django入门与实践-第27章：项目部署
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >Django入门与实践-第17章：保护视图</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="django&#x5165;&#x95E8;&#x4E0E;&#x5B9E;&#x8DF5;-&#x7B2C;17&#x7AE0;&#xFF1A;&#x4FDD;&#x62A4;&#x89C6;&#x56FE;">Django&#x5165;&#x95E8;&#x4E0E;&#x5B9E;&#x8DF5;-&#x7B2C;17&#x7AE0;&#xFF1A;&#x4FDD;&#x62A4;&#x89C6;&#x56FE;</h1>
<p><img src="statics/5-1.jpg" alt="5-1.jpg"></p>
<h3 id="&#x524D;&#x8A00;">&#x524D;&#x8A00;</h3>
<p>&#x6B22;&#x8FCE;&#x6765;&#x5230;&#x672C;&#x7CFB;&#x5217;&#x6559;&#x7A0B;&#x7684;&#x7B2C;5&#x90E8;&#x5206;&#xFF0C;&#x5728;&#x8FD9;&#x8282;&#x8BFE;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x5B66;&#x4E60;&#x5982;&#x4F55;&#x4FDD;&#x62A4;&#x89C6;&#x56FE;&#x9632;&#x6B62;&#x672A;&#x767B;&#x5F55;&#x7684;&#x7528;&#x6237;&#x8BBF;&#x95EE;&#xFF0C;&#x4EE5;&#x53CA;&#x5728;&#x89C6;&#x56FE;&#x548C;&#x8868;&#x5355;&#x4E2D;&#x8BBF;&#x95EE;&#x5DF2;&#x7ECF;&#x767B;&#x5F55;&#x7684;&#x7528;&#x6237;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x5C06;&#x5B9E;&#x73B0;&#x4E3B;&#x9898;&#x5217;&#x8868;&#x548C;&#x56DE;&#x590D;&#x5217;&#x8868;&#x89C6;&#x56FE;&#xFF0C;&#x6700;&#x540E;&#xFF0C;&#x5C06;&#x63A2;&#x7D22; Django ORM &#x7684;&#x4E00;&#x4E9B;&#x7279;&#x6027;&#x548C;&#x6570;&#x636E;&#x8FC1;&#x79FB;&#x7684;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;&#x3002;</p>
<h3 id="&#x4FDD;&#x62A4;&#x89C6;&#x56FE;">&#x4FDD;&#x62A4;&#x89C6;&#x56FE;</h3>
<p>&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x4FDD;&#x62A4;&#x89C6;&#x56FE;&#x9632;&#x6B62;&#x90A3;&#x4E9B;&#x672A;&#x8BA4;&#x8BC1;&#xFF08;&#x767B;&#x5F55;&#xFF09;&#x7684;&#x7528;&#x6237;&#x8BBF;&#x95EE;&#xFF0C;&#x4E0B;&#x9762;&#x662F;&#x53D1;&#x8D77;&#x4E00;&#x4E2A;&#x65B0;&#x8BDD;&#x9898;&#x7684;&#x9875;&#x9762;</p>
<p><img src="statics/5-2.png" alt="5-2.png"></p>
<p>&#x5728;&#x4E0A;&#x56FE;&#x4E2D;&#xFF0C;&#x7528;&#x6237;&#x8FD8;&#x6CA1;&#x6709;&#x767B;&#x5F55;&#xFF0C;&#x5C3D;&#x7BA1;&#x4ED6;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x9875;&#x9762;&#x548C;&#x8868;&#x5355;&#x3002;Django &#x6709;&#x4E00;&#x4E2A;&#x5185;&#x7F6E;&#x7684; <em>&#x89C6;&#x56FE;&#x88C5;&#x9970;&#x5668;</em> &#x6765;&#x907F;&#x514D;&#x5B83;&#x88AB;&#x672A;&#x767B;&#x5F55;&#x7684;&#x7528;&#x6237;&#x8BBF;&#x95EE;&#xFF1A;</p>
<p><strong>boards/views.py</strong>&#xFF08;<a href="https://gist.github.com/vitorfs/4d3334a0daa9e7a872653a22ff39320a#file-models-py-L19" target="_blank">&#x5B8C;&#x6574;&#x4EE3;&#x7801;</a>&#xFF09;</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.contrib.auth.decorators <span class="hljs-keyword">import</span> login_required

<span class="hljs-meta">@login_required</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">new_topic</span><span class="hljs-params">(request, pk)</span>:</span>
    <span class="hljs-comment"># ...</span>
</code></pre>
<p>&#x73B0;&#x5728;&#x5982;&#x679C;&#x7528;&#x6237;&#x6CA1;&#x6709;&#x767B;&#x5F55;&#xFF0C;&#x5C06;&#x88AB;&#x91CD;&#x5B9A;&#x5411;&#x5230;&#x767B;&#x5F55;&#x9875;&#x9762;&#xFF1A;</p>
<p><img src="statics/5-3.png" alt="5-3.png"></p>
<p>&#x6CE8;&#x610F;&#x67E5;&#x8BE2;&#x5B57;&#x7B26;&#x4E32; <strong>?next=/boards/1/new/</strong> &#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x6539;&#x8FDB;&#x767B;&#x5F55;&#x6A21;&#x677F;&#x4EE5;&#x4FBF;&#x5229;&#x7528; <strong>next</strong> &#x53D8;&#x91CF;&#x6765;&#x6539;&#x8FDB;&#x6211;&#x4EEC;&#x7684;&#x7528;&#x6237;&#x4F53;&#x9A8C;&#xFF0C;&#xFF08;&#x8BD1;&#x6CE8;&#xFF1A;&#x5B9E;&#x9645;&#x4E0A;&#x8FD9;&#x6B65;&#x64CD;&#x4F5C;&#x4E0D;&#x52A0;&#x4E5F;&#x6CA1;&#x95EE;&#x9898;&#xFF09;</p>
<h3 id="&#x914D;&#x7F6E;&#x767B;&#x5F55;&#x540E;&#x7684;&#x91CD;&#x5B9A;&#x5411;&#x5730;&#x5740;">&#x914D;&#x7F6E;&#x767B;&#x5F55;&#x540E;&#x7684;&#x91CD;&#x5B9A;&#x5411;&#x5730;&#x5740;</h3>
<p><strong>templates/login.html</strong> (<a href="https://gist.github.com/vitorfs/1ab597fe18e2dc56028f7aa8c3b588b3#file-login-html-L13" target="_blank">&#x67E5;&#x770B;&#x5B8C;&#x6574;&#x5185;&#x5BB9;</a>)</p>
<pre><code class="lang-python">&lt;form method=&quot;post&quot; novalidate&gt;
  {% csrf_token %}
  &lt;input type=&quot;hidden&quot; name=&quot;next&quot; value=&quot;{{ next }}&quot;&gt;
  {% include &apos;includes/form.html&apos; %}
  &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary btn-block&quot;&gt;Log in&lt;/button&gt;
&lt;/form&gt;
</code></pre>
<p>&#x73B0;&#x5728;&#x5C1D;&#x8BD5;&#x767B;&#x5F55;&#xFF0C;&#x767B;&#x5F55;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4F1A;&#x8DF3;&#x8F6C;&#x5230;&#x539F;&#x6765;&#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#x3002;</p>
<p><img src="statics/5-4.png" alt="5-4.png"></p>
<p><strong>next</strong> &#x53C2;&#x6570;&#x662F;&#x5185;&#x7F6E;&#x529F;&#x80FD;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF08;&#x8BD1;&#x6CE8;&#xFF1A;&#x8BE6;&#x60C5;&#x8BF7;&#x53C2;&#x8003;Django<a href="https://docs.djangoproject.com/en/2.0/topics/auth/default/#the-login-required-decorator" target="_blank">&#x5B98;&#x65B9;&#x6587;&#x6863;</a>&#xFF09;</p>
<h3 id="&#x6D4B;&#x8BD5;">&#x6D4B;&#x8BD5;</h3>
<p>&#x73B0;&#x5728;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;&#x786E;&#x4FDD;&#x4E3B;&#x9898;&#x53D1;&#x5E03;&#x89C6;&#x56FE;&#x88AB; <code>@login_required</code>&#x88C5;&#x9970;&#x5668;&#x4FDD;&#x62A4;&#x4E86;&#xFF0C;&#x4E0D;&#x8FC7;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x662F;&#x5148;&#x6765;&#x91CD;&#x6784;&#x4E00;&#x4E0B; <strong>boards/tests/test_views.py</strong> &#x6587;&#x4EF6;&#x3002;</p>
<p>&#x628A;<strong>test_views.py</strong>&#x62C6;&#x5206;&#x6210;3&#x4E2A;&#x6587;&#x4EF6;&#xFF1A;</p>
<ul>
<li><strong>test_view_home.py</strong> &#x5305;&#x542B; HomeTests &#x7C7B; &#xFF08;<a href="https://gist.github.com/vitorfs/6ac3aad244c856d418f18890efcb4a7e#file-test_view_home-py" target="_blank">&#x5B8C;&#x6574;&#x4EE3;&#x7801;</a>&#xFF09;</li>
<li><strong>test_view_board_topics.py</strong> &#x5305;&#x542B; BoardTopicsTests &#x7C7B;&#xFF08;<a href="https://gist.github.com/vitorfs/6ac3aad244c856d418f18890efcb4a7e#file-test_view_board_topics-py" target="_blank">&#x5B8C;&#x6574;&#x4EE3;&#x7801;</a>&#xFF09;</li>
<li><strong>test_view_new_topic.py</strong> &#x5305;&#x542B; NewTopicTests &#x7C7B;&#xFF08;<a href="https://gist.github.com/vitorfs/6ac3aad244c856d418f18890efcb4a7e#file-test_view_new_topic-py" target="_blank">&#x5B8C;&#x6574;&#x4EE3;&#x7801;</a>&#xFF09;</li>
</ul>
<pre><code class="lang-shell">myproject/
 |-- myproject/
 |    |-- accounts/
 |    |-- boards/
 |    |    |-- migrations/
 |    |    |-- templatetags/
 |    |    |-- tests/
 |    |    |    |-- __init__.py
 |    |    |    |-- test_templatetags.py
 |    |    |    |-- test_view_home.py          &lt;-- here
 |    |    |    |-- test_view_board_topics.py  &lt;-- here
 |    |    |    +-- test_view_new_topic.py     &lt;-- and here
 |    |    |-- __init__.py
 |    |    |-- admin.py
 |    |    |-- apps.py
 |    |    |-- models.py
 |    |    +-- views.py
 |    |-- myproject/
 |    |-- static/
 |    |-- templates/
 |    |-- db.sqlite3
 |    +-- manage.py
 +-- venv/
</code></pre>
<p> &#x91CD;&#x65B0;&#x8FD0;&#x884C;&#x6D4B;&#x8BD5;&#xFF0C;&#x786E;&#x4FDD;&#x4E00;&#x5207;&#x6B63;&#x5E38;&#x3002;</p>
<p> &#x73B0;&#x5728;&#x5728; <strong>test_view_new_topic.py</strong> &#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x65B0;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;&#xFF0C;&#x7528;&#x6765;&#x68C0;&#x67E5;&#x8BD5;&#x56FE;&#x662F;&#x5426;&#x88AB;<code>@login_required</code>&#x4FDD;&#x62A4;&#xFF1A;</p>
<p> <strong>boards/tests/test_view_new_topic.py</strong> &#xFF08;<a href="https://gist.github.com/itorfs/13e75451396d76354b476edaefadbdab#file-test_view_new_topic-py-L84" target="_blank">&#x5B8C;&#x6210;&#x4EE3;&#x7801;</a>&#xFF09;</p>
<pre><code class="lang-python"> <span class="hljs-keyword">from</span> django.test <span class="hljs-keyword">import</span> TestCase
<span class="hljs-keyword">from</span> django.urls <span class="hljs-keyword">import</span> reverse
<span class="hljs-keyword">from</span> ..models <span class="hljs-keyword">import</span> Board

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LoginRequiredNewTopicTests</span><span class="hljs-params">(TestCase)</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">setUp</span><span class="hljs-params">(self)</span>:</span>
        Board.objects.create(name=<span class="hljs-string">&apos;Django&apos;</span>, description=<span class="hljs-string">&apos;Django board.&apos;</span>)
        self.url = reverse(<span class="hljs-string">&apos;new_topic&apos;</span>, kwargs={<span class="hljs-string">&apos;pk&apos;</span>: <span class="hljs-number">1</span>})
        self.response = self.client.get(self.url)

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">test_redirection</span><span class="hljs-params">(self)</span>:</span>
        login_url = reverse(<span class="hljs-string">&apos;login&apos;</span>)
        self.assertRedirects(self.response, <span class="hljs-string">&apos;{login_url}?next={url}&apos;</span>.format(login_url=login_url, url=self.url))
</code></pre>
<p>&#x5728;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5C1D;&#x8BD5;&#x5728;&#x6CA1;&#x6709;&#x767B;&#x5F55;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x53D1;&#x9001;&#x8BF7;&#x6C42;&#x7ED9; <strong>new topic</strong> &#x89C6;&#x56FE;&#xFF0C;&#x671F;&#x5F85;&#x7684;&#x7ED3;&#x679C;&#x662F;&#x8BF7;&#x6C42;&#x91CD;&#x5B9A;&#x5411;&#x5230;&#x767B;&#x5F55;&#x9875;&#x9762;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Authentication2.html" class="navigation navigation-prev " aria-label="Previous page: Django入门与实践-第16章：用户登录">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="DjangoORM1.html" class="navigation navigation-next " aria-label="Next page: Django入门与实践-第18章：实现主题回复列表">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Django入门与实践-第17章：保护视图","level":"1.18","depth":1,"next":{"title":"Django入门与实践-第18章：实现主题回复列表","level":"1.19","depth":1,"path":"DjangoORM1.md","ref":"./DjangoORM1.md","articles":[]},"previous":{"title":"Django入门与实践-第16章：用户登录","level":"1.17","depth":1,"path":"Authentication2.md","ref":"./Authentication2.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["include-codeblock","livereload"],"pluginsConfig":{"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"default","theme":"chrome","unindent":false},"livereload":{},"highlight":{},"search":{},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"sharing":{"all":["facebook","google","instapaper","twitter","weibo"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"theme-default":{"showLevel":false,"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}},"file":{"path":"DjangoORM0.md","mtime":"2018-05-13T13:48:46.861Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-05-13T12:52:49.928Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

